import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home'
import Admin from '../views/Admin'
import M from '../views/M'
import AdminHome from '../views/admin/AdminHome'
import MHome from '../views/m/MHome'

Vue.use(VueRouter)

  const routes = [
    {
      path: '/',
      name: 'Home',
      component: Home
    },
    {
      path: '/m',
      name: 'm',
      component: M,
      children: [
        {
          path: '',
          name: 'm-home',
          component: MHome
        },
        {
          path: 'news/:id',
          name: 'm-news-show',
          component: () => import('../views/m/MNewsShow')
        },
        {
          path: 'vip',
          name: 'm-vip',
          component: () => import('../views/m/MVip')
        },
        {
          path: 'setting',
          name: 'm-setting',
          component: () => import('../views/m/MSetting')
        },
        {
          path: 'mine',
          name: 'm-mine',
          component: () => import('../views/m/MMine')
        },
      ]
    },
    {
      path: '/admin',
      name: 'admin',
      component: Admin,
      children: [
        {
          path: '',
          name: 'admin-home',
          component: AdminHome
        },
        // /admin/news
        {
          path: 'news',
          name: 'admin-news',
          component: () => import('../views/admin/AdminNews')
        },
        {
          path: 'news/create',
          name: 'admin-news-create',
          component: () => import('../views/admin/AdminNewsCreate')
        },
        {
          path: 'news/:newsId/edit',
          name: 'admin-news-edit',
          component: () => import('../views/admin/AdminNewsEdit')
        },
        {
          path: 'news/:newsId',
          name: 'admin-news-show',
          component: () => import('../views/admin/AdminNewsShow')
        },
      ]
    },
    {
      path: '/about',
      name: 'About',
      component: () => import('../views/About.vue')
    }
  ]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes,
  linkExactActiveClass: 'active'
})

export default router
